/**
 * @module api/lib
 */

import { service as $axios } from './request';

class send {
  /**
   * @param ajax {import('axios').AxiosInstance}
   */
  constructor(ajax) {
    this.$ajax = ajax;
  }
}

/**
 * @description post数据处理中心
 * @param url {string}
 * @param [data] {any}
 * @param [config] {import('axios').AxiosResponse}
 * @returns {Promise<any>}
 */
send.prototype.post = async function post(url, data, config) {
  const res = await this.$ajax.post(url, data, config);
  if (res.respCode === 0) {
    return res.obj;
  }
  throw res;
};

export default new send($axios);
